export default function detailCanvas(that,sWidth,sHeight,headimgUrl,imgUrl,codeImg,title,nickName,callback){
  let rpx = sWidth;
  const cxt = wx.createCanvasContext('myCanvas',that);
  cxt.save();
  cxt.setFillStyle('#fff')
  cxt.fillRect(0, 0, sWidth*375, sHeight-100);
  var avatorWidth = sWidth *50,avatorHeight = sWidth * 50;
  var avatarurlX =sWidth*10; 
  var avatarurlY =5;
  console.log('头像:')
  console.log(headimgUrl)
  cxt.save();
  cxt.beginPath();
  cxt.arc(avatorWidth / 2 + avatarurlX, avatorHeight / 2 + avatarurlY, avatorWidth / 2, 0, Math.PI * 2, false);
  cxt.clip();
  cxt.drawImage(headimgUrl,sWidth*10,5, avatorWidth, avatorWidth);
  cxt.restore();
  cxt.setFillStyle('#333333');
  cxt.setFontSize('14');
  cxt.fillText(nickName+'为你分享直播',70,avatorWidth/2+10);
  let detailImgHeight = (sWidth*375)*12/16;
  cxt.drawImage(imgUrl,10,10+sWidth*50,sWidth*375-sWidth*90,detailImgHeight);
 
  //二维码
  cxt.drawImage(codeImg,(sWidth*375-155*rpx),360*rpx,60*rpx,60*rpx);
  cxt.restore();
  cxt.setFillStyle('#333333');
  cxt.setFontSize('12');
  cxt.fillText('扫描或长按小程序码',(sWidth*375-180*rpx),440*rpx);
  //标题
  cxt.setFontSize(14);
  cxt.setFillStyle('#333333');
  if(title.length>14){
      cxt.fillText(title.slice(0,14),10*rpx,375*rpx);
      if(title.length>28)
      {
        cxt.fillText(title.slice(14,title.length)+'...',10*rpx,395*rpx);
      }
      else
      {
        cxt.fillText(title.slice(14,title.length),10*rpx,395*rpx);
      }
  }
  else
  {
    cxt.fillText(title,10*rpx,375*rpx);
  }
  
  cxt.setFontSize(14);
  cxt.setFillStyle('#333333');
  
  cxt.draw(false,()=>{
      wx.canvasToTempFilePath({
          x: 0,
          y: 0,
          canvasId:"myCanvas",
          fileType: 'png',
          success: (res)=>{
              callback(res.tempFilePath)
          },
         
      }, that);
  });
}